package be.phl.android.project;

import persist.Dagmenu;
import android.app.Activity;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.widget.TextView;

public class DagmenuActivity extends Activity {
	TextView tv;

	private void loadData() throws Exception {
		Dagmenu dagmenu = null;
		String output = "";
		JsonHandler handler = JsonHandler.getInstance();
		dagmenu = handler.getDagmenu();
		if (dagmenu == null)
			throw new Exception(
					"Geen dagmenu gevonden! Probeer up te daten of later opnieuw!");
		output = dagmenu.toString();
		tv.setText(output);
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		try {
			// TODO Auto-generated method stub
			super.onCreate(savedInstanceState);
			setContentView(R.layout.overzicht);

			tv = (TextView) findViewById(R.id.overzicht);
			loadData();
			tv.setMovementMethod(new ScrollingMovementMethod());
		} catch (Exception e) {
			// Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT);
			finish();
		}
	}

	@Override
	protected void onRestart() {
		try {
			super.onRestart();
			loadData();
		} catch (Exception e) {
			// Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT);
			finish();
		}
	}
}
